SCRIPTS

Introduction

A major feature of Proteus is its ability to support free format text scripts, and the numerous uses it puts them to. These uses include:

  • Defining variables for use in property expressions and parameter mapping.
  • Defining primitive models and scripts for use with the VSM simulators.
  • Annotating designs with substantial quantities of text.
  • Storing property and packaging information when a component is decomposed.

Placing and Editing Scripts

The procedures for placing and editing scripts are almost identical, as both operations involve the Edit Script Block dialogue form.

To place a script:

  1. Select the Script Icon from the Mode Selector toolbar.
  2. In the Editing Window, point to where you want the top-left of the script to be and click left to launch the Edit Script Block dialogue as shown below.

    The Edit Script Block dialogue form
  3. Enter the text for the new script in the Text field. You can also adjust the attributes of a script at this time; see To Edit a Script below for full details of the dialogue form.
  4. Close the dialogue form with the OK button to place the new script or with the CANCEL button to quit the form and cancel the script placement.

To edit a script:

  1. Either:
    (a) Tag the script by pointing at it and clicking right, then select Edit Properties from the resulting context menu.
    (b) Point at the script with the mouse and use the assigned keyboard shortcut to edit it (by default this is CTRL+E).
    (c) Enter Selection mode via the selection icon and double click on the script block.
  2. Adjust the script attributes as required.
  3. Close the Form. To close the form and save changes either click the OK button or use the CTRL+ENTER keys. To close the form and abandon changes, either click the CANCEL button or use the ESC key.

See Local Styles for more details of editing local text styles.

See Edit Script Block for the controls on the dialogue form.

You can resize the Edit Script Block dialogue form to make the Text field bigger.

Script Block Types

Proteus currently supports the following script block types:

Script Block Type

Block Header

Part Property Assignment

*FIELD

Sheet Global Net Property Assignment

*NETPROP

Sheet Property Definition

*DEFINE

Parameter Mapping Table

*MAP ON varname

Model Definition File

*MODELS

Named Script

*SCRIPT type name

Part Property Assignments (*FIELD)

Field blocks are deprecated for new designs. Non-physical parts can be packaged directly in the layout module and properties added through the Bill of Materials property editor.

See Physical Terminals for more information on physical terminals.

See Schematic and Layout regarding packaging considerations for PCB Design.

Field blocks are primarily intended to facilitate the assignment of properties to connectors made from physical terminals. A special means to do this is required since when physical terminals are used, there is no single entity on the schematic that represents the connector and to which properties could be directly attached.

An example block is shown below:

*FIELD

J1,PACKAGE=CONN-D9

J2,PACKAGE=CONN-D25

This assigns connector J1 the PCB package for a 9 pin D connector, and J2 the package for a 25 way connector.

You can assign properties to ordinary components as well, but there is generally little point since you can add them directly to the components.

A field block is read only when the physical netlist is generated, so it affects the PCB and Bill of Materials outputs and never the simulation.

Sheet Global Net Property Assignments (*NETPROP)

A net property is normally assigned by the placement of a wire label with the syntax:

<prop>=<value>

However, there are occasions when you wish a large number of nets to carry the same property. Most often, the requirement is for all the circuitry on a particular sheet to be of a particular type (perhaps extra wide tracking for a power supply) and it is for this purpose that a NETPROP block may be used. For example, if the block:

*NETPROP

CLASS=POWER

is included on a sheet, then all nets whose wires do not carry explicit net properties will be assigned the net property CLASS=POWER.

See Using a Wire Label to Assign a Net Property for more information about net properties.

Sheet Property Definitions (*DEFINE)

A sheet property is essentially a variable which is defined on a given sheet and may be used in property expressions within components' property lists on that sheet. Sheet properties defined on the root sheets of a design, also appear in the netlist and may be used as control parameters by software such as the VSM simulators that reads the netlist.

An example block is shown below:

*DEFINE

TEMP=40

MINSTEPS=100

This defines two properties TEMP and MINSTEPS, and would be placed on the root sheet of a design such that they would be passed to VSM as simulation control parameters.

Parameter Mapping Tables (*MAP ON varname)

This is considered a highly advanced topic, and one which is only of great importance if you are involved in creating universal models for use with VSM. Further information on this is given in the VSM manual, but for completeness, we provide an example parameter mapping table here:

*MAP ON VALUE

7400   : TDLH=12n,TDHL=7n

74LS00 : TDLH=10n,TDHL=6n

74S00  : TDLH=5n,TDHL=3n

This table would be placed on the model schematic for a 2 input NAND gate, and would select different values for TDLH and TDHL according to the value (i.e. type) of the parent object. Also on the child sheet would be a NAND_2 primitive with the properties:

TDLH=<TDLH>

TDHL=<TDHL>

At netlist time, the parameter mapping table would examine the parent object's VALUE property and if, say, it were 74LS00, then the sheet properties TDLH=10n and TDHL=6n would be defined for that instance of the model. Then, on processing the NAND_2 primitive, these values would be substituted for <TDLH> and <TDHL> such that the primitive would acquire the correct timing to model a 74LS00.

A DEFAULT case is also supported.

Model Definition Tables (*MODELS)

These blocks are used only with the VSM simulators (currently, in fact, only with the Analogue simulator) and provide a shorthand method for managing the large numbers of properties that some of the simulator primitives use. For example, the bipolar transistor model has over 30 different properties and it would be fairly hopeless if you had to assign all of these individually for each transistor on the circuit.

Instead, you can use a MODELS block to define the properties for a particular type of transistor, and then refer to that set of properties using a model name.

An example block is shown below:

*MODELS

741_NPN : BETAF=80,ISAT=1E-14,RB=100,VAF=50,\

          TAUF=0.3E-9,TAUR=6E-9, CJE=3E-12,CJC=2E-12

741_PNP : BETAF=10,ISAT=1E-14,RB=20, VAF=50,\

          TAUF=1E-9,  TAUR=20E-9,CJE=6E-12,CJC=4E-12

This defines the two transistor types used in a 741 IC. Individual transistors could then be given the values 741_NPN or 741_PNP and VSM would automatically give them the characteristics defined in the model table.

See the VSM manual for further discussion of primitive models.

Named Scripts (*SCRIPT scripttype scriptname)

In certain circumstances it is useful to be able to export a named block of text to an external application. In particular, ProSPICE collects a script named SPICE into the deck that it simulates, and the SPICE-AGE netlist formatter reads a script named SPICEAGE for its control information.

A typical named script block is shown below. Note that the end of the named script must be marked by an ENDSCRIPT keyword. If the terminator is missing the script is discarded and an error is logged, so it is not optional.

*SCRIPT PROGRAM 7493

// Declare linkage to pins and local variables:

PIN CKA, CKB, RA, RB

PIN QA,QB,QC,QD

INT counta = 0, countb = 0

// Handle single-bit 'A' counter and assign output:

IF RA=H THEN

   counta = 0

ELIF CKA=HL THEN

   counta = (counta+1) % 2

ENDIF

QA = counta & 1

// Handle three-bit 'B' counter and assign output:

IF RB=H THEN

   countb = 0

ELIF CKB=HL THEN

   countb = (countb+1) % 8

ENDIF

QB = countb & 1

QC = countb & 2

QD = countb & 4

*ENDSCRIPT

SPICE and SPICE-AGE Scripts

Everything you type after the *SCRIPT keyword becomes the name of the script, so a single word is a perfectly good name. A named script is the route by which SPICE input cards are typed on the schematic and loaded directly into ProSPICE at simulate time, which is handy if you want to develop or test a model in native SPICE format. Name the script SPICE and its contents are appended to the deck:

*SCRIPT SPICE

.MODEL QMOD NPN (BF=100 IS=1E-16 VAF=50)

*ENDSCRIPT

A script named SPICEAGE is read in the same way by the SPICE-AGE netlist formatter.

Further information on this is provided in the Proteus VSM manual.